<template>
	<view class="">
		<view class="yuanhu"></view>
		<view class="head">
			<image :src="redData.user.avatar" mode=""></image>
			<text>{{redData.user.nickname}}</text>
		</view>
		<view class="list">
			<view class="card flex">
				<view class="left">
					<view class="price">￥<text class="f40 bold">{{redData.price}}</text></view>
					<view class="tj f24" v-if="redData.use_min_price > 0">满￥{{redData.use_min_price}}可用</view>
					<view class="tj f24" v-else>无门槛</view>
				</view>
				<view class="right">
					<view class="one">{{redData.red_name}}</view>
					<view class="two f24" v-if="redData.end_date">有效期： {{redData.create_date.slice(0,10)}} -
						{{redData.end_date.slice(0,10)}}
					</view>
					<view class="two f24" v-else>不限</view>
				</view>
			</view>
		</view>
		<view class="desc">描述: {{redData.redinfo?redData.redinfo:'无描述'}}</view>
		<view class="lingqu" v-if="redData.is_my_receive == 0" @click="setget">
			立即领取
		</view>
		<view class="lingqu2" v-else>
			已领取
			<!-- <text style="font-size: 30rpx;">￥</text><text>300</text> -->
		</view>
		<view class="lines"></view>
		<view class="listbg">
			<view class="listitem" v-for="item in redData.receive">
				<view class="listiteml">
					<image :src="item.user.avatar" mode=""></image>
					<view class="">
						<text>{{item.user.nickname}}</text>
						<text>{{item.create_date}}</text>
					</view>
				</view>
				<view class="listitemr">{{item.red_packet_price}}元</view>
			</view>


		</view>

	</view>
</template>

<script>
	import {
		getFissionRedDetailsApi,
		userGetFiRedApi
	} from '@/api/user.js'
	import Cache from '@/util/cache.js'

	export default {
		data() {
			return {
				isget: true,
				redData: {},
				e: {}
			}
		},
		onLoad(e) {
			this.e = e
			this.detailsx()
			if(e.spread_spid){
				Cache.set('spread_spid', e.spread_spid)
			}
		},
		created() {

		},
		onShow() {

		},
		methods: {
			detailsx() {
				getFissionRedDetailsApi(this.e).then(res => {
					this.redData = res.data
				}).catch(err => {
					uni.showToast({
						title: err.message,
						icon: "none"
					})
				})
			},
			setget() {
				userGetFiRedApi(this.e).then(res => {
					uni.showToast({
						title: `恭喜领取到${res.data.red_packet_price}红包`,
						icon: "none"
					})
					// this.isget = false
					this.detailsx()
				}).catch(err => {
					uni.showToast({
						title: err.message,
						icon: "none"
					})
				})
			},

		}
	}
</script>

<style lang="scss">
	.lines {
		height: 20rpx;
		width: 100%;
		background: #f5f5f5;
		margin-top: 30rpx;
	}

	.listbg {
		margin-top: 39rpx;
	}

	.listitem {
		width: 690rpx;
		height: 140rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-left: 30rpx;
		border-bottom: 1rpx solid #ededed;
	}

	.listiteml {
		display: flex;
		align-items: center;

	}

	.listiteml image {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		background: #999;
		margin-right: 10rpx;
	}

	.listiteml>view {
		display: flex;
		flex-direction: column;
		font-size: 28rpx;
		font-family: Microsoft YaHei;
		color: #333333;
		// align-items: center;
		justify-content: center;
	}

	.listiteml>view text:nth-of-type(2) {
		color: #999999;
		margin-top: 10rpx;
	}

	.listitemr {
		font-size: 28rpx;
		color: #333;
	}

	.yuanhu {
		width: 100%;
		height: 100rpx;
		background: linear-gradient(180deg, #F83535 0%, #F83535 100%);
		border-radius: 100% 100% 100% 100% / 0% 0% 40% 40%;

	}

	.desc {
		color: #999;
		font-size: 24rpx;
		flex: 1;
		width: 690rpx;
		margin-left: 30rpx;
	}

	.lingqu {
		margin-left: 30rpx;
		margin-top: 30rpx;
		width: 690rpx;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		background: #FFFFFF;
		border: 1rpx solid #F83535;
		border-radius: 50rpx;
		font-size: 30rpx;
		color: #F83535;
	}

	.lingqu2 {
		margin-left: 30rpx;
		margin-top: 30rpx;
		width: 690rpx;
		height: 100rpx;
		display: flex;
		justify-content: center;
		font-size: 30rpx;
		font-family: Microsoft YaHei;
		color: #999;
		align-items: baseline;
	}

	.lingqu2 text {
		font-weight: bold;
		font-size: 60rpx;
		color: #F83535;
	}

	.head {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 30rpx;
	}

	.head image {
		width: 80rpx;
		height: 80rpx;
		background: #ccc;
		border-radius: 50%;
		margin-right: 30rpx;
	}

	.packageinfo {
		width: 690rpx;
		height: 300rpx;
		margin-top: 30rpx;
		margin-left: 30rpx;
		background: #ccc;
	}

	.list {
		// min-height: calc(100vh - 96rpx);
		// background-color: #F5F5F5;
		// padding: 0 30rpx 30rpx;
		// box-sizing: border-box;
		margin-left: 30rpx;

		.card {
			position: relative;
			margin-bottom: 20rpx;
			width: 690rpx;
			// height: 186rpx;
			padding: 23rpx 28rpx 23rpx 0;
			background: #FFFFFF;
			border-radius: 10rpx;
			box-sizing: border-box;
			margin-top: 30rpx;
			border: 1rpx dashed #ccc;

			.left {
				flex-shrink: 0;
				width: 200rpx;
				height: 160rpx;
				border-right: 1rpx dashed #CCCCCC;
				text-align: center;
				color: #F83535;

				.price {
					margin-top: 28rpx;
				}

				.tj {
					margin-top: 6rpx;
					color: #666;
				}
			}

			.right {
				position: relative;
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				font-size: 28rpx;

				.two {
					margin: 28rpx 0;
					color: #666;
				}

				.three {
					color: #999;
					font-size: 24rpx;
					overflow: hidden;

					.desc {
						flex: 1;
						width: 420rpx;
					}

					.icon {
						flex-shrink: 0;
						margin-left: 20rpx;
						width: 26rpx;
						height: 14rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}
				}



				.get {
					border: 1rpx solid #ccc;
					color: #666;
				}
			}
		}
	}
</style>
